//package com.ocom.xfrecode.config;
//
//import com.google.common.collect.Range;
//import com.ocom.xfrecode.constant.ShardingConstant;
//import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
//import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;
//
//import java.util.Collection;
//import java.util.LinkedHashSet;
//
///**
// * @BelongsProject: DemoCode
// * @BelongsPackage:
// * @Author: hef
// * @CreateTime: 2021-07-09 17:22
// * @Description:
// */
//public class CustomTableRangeShardingAlgorithm implements RangeShardingAlgorithm<String> {
//	public CustomTableRangeShardingAlgorithm() {
//	}
//
//
//	@Override
//	public Collection<String> doSharding(Collection<String> collection, RangeShardingValue<String> rangeShardingValue) {
//		Range<String> ranges = rangeShardingValue.getValueRange();
//		Integer startYM = 0;
//		if (ranges.hasLowerBound()) {
//			String lower = ranges.lowerEndpoint();
//			startYM = Integer.valueOf(lower);
//		}
//		Integer endYM = 0;
//		if (ranges.hasUpperBound()) {
//			String upper = ranges.upperEndpoint();
//			endYM = Integer.valueOf(upper);
//		}
//		Collection<String> tables = new LinkedHashSet<>();
//		if (judgmentTime(startYM, endYM)) {
//			for (String c : collection) {
//				String substring = c.substring(c.length() - ShardingConstant.DATE_SHARDING_TABLE_FORMAT.length());
//				Integer cMonth = Integer.valueOf(substring);
//				if (startYM != 0 && endYM != null) {
//					if (cMonth >= startYM && cMonth <= endYM) {
//						tables.add(c);
//					}
//				} else if ((startYM != 0 && cMonth >= startYM) || (endYM != 0 && cMonth <= endYM)) {
//					tables.add(c);
//				}
//			}
//		}
//		return tables;
//	}
//
//	public boolean judgmentTime(Integer start, Integer end) {
//		if (start == null && end == null) {
//			throw new IllegalArgumentException("no valid time");
//		}
//		if (start != null && end != null) {
//			return start <= end;
//		}
//		return true;
//	}
//}
//
